<?php
include ('ModelConexion.php'); 

class Usuarios extends Conexion
{

	public $M_Cedula;
	public $M_Password;
	private $M_tipo;
	public $mensajeL;

	
	
	public function login($Cedula,$password)
	{	
		if($Cedula != '' && $password != '')
		{
			$objeto = new Conexion();			
			$consulta = $objeto->consulta("
				SELECT `Id_Admin`,`Tipo_Us`,`Password`
				FROM `ctp`.`tb_usuario`
				WHERE Id_Admin='$Cedula'
				AND Password = $password
				");

				if($objeto->numero_filas($consulta) == 1)
				{
					

					while($Arreglo= $objeto->f_array($consulta))
					{
						$tipo=$Arreglo['Tipo_Us'];
						switch ($tipo) 
						{
							case 'Administrador':
								$_SESSION['Id_Admin'] = $Arreglo['Id_Admin'];
								header('Location:../View/V_Inicio.php');
								break;
							case 'Funcionario':
							    $_SESSION['Id_Admin'] = $Arreglo['Id_Admin'];
								header('Location:../View/V_Inicio_Fun.php');
								break;
							default:
								echo "Error";
								break;
						}

					}
					
				}
				else
				{
					header('Location:../View/V_Abrir_Sesion.php');
				}

		}
		else
		{
			header('Location:../View/ViewLogin.php');
		}

	}
}

?>